package com.ymatou.query.trading.api.testcase;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.query.trading.api.parameter.GetTradingOrderPriceBean;
import com.ymatou.query.trading.api.service.GetTradingOrderPriceCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymt.utils.tag.P3;
import com.ymttest.utils.constant.ECode;

/**
 * 获取当前交易相关订单金额信息 FreeMaker Template自动生成代码
 */
@TestSuite
public class Ts_GetTradingOrderPrice {
	private static GetTradingOrderPriceBean gtopbean;
	private static GetTradingOrderPriceCall gtopcall;

	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("获取当前交易相关订单金额信息");
	}

	@Before
	public void caseUp() {
		gtopbean = new GetTradingOrderPriceBean();
		gtopcall = new GetTradingOrderPriceCall();

	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(gtopcall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetTradingOrderPrice_001() {
		Logger.start(true,"获取当前交易相关订单金额信息成功");
		try {
			/*
			 * Map map = new OrderCallService().createOrder(1); int TradingId =
			 * (Integer) map.get("TradingId");
			 */
			int TradingId = 8044219;// sit
			Logger.comment("交易ID:" + TradingId);
			gtopbean.setTradingId(TradingId);
			// 发送请求
			gtopcall.setData(gtopbean);
			gtopcall.callService();
			Logger.comment("gtopcall send:" + gtopcall.getEntityString());
			Logger.comment("gtopcall response:" + gtopcall.getReturnData());
			Logger.verifyEquals(ECode.SUCCESS, gtopcall.getCode(), "验证Code");
			// Logger.verifyEquals(ErrorCode.SUCCESSMSG2, gtopcall.getMsg(),
			// "验证Msg");
			Logger.verifyEquals(true, gtopcall.getOrderPrice() > 0, "验证OrderPrice");
			Logger.verifyEquals(true, gtopcall.getTotalNeedPayPrice() > 0, "验证TotalNeedPayPrice");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_GetTradingOrderPrice_002() {
		Logger.start(true,"交易号为空");
		try {
			/*
			 * Map map = new OrderCallService().createOrder(1); int TradingId =
			 * (Integer) map.get("TradingId");
			 */
			int TradingId = 8044219;// sit
			// gtopbean.setTradingId(TradingId);
			// 发送请求
			gtopcall.setData(gtopbean);
			gtopcall.callService();
			Logger.comment("gtopcall send:" + gtopcall.getEntityString());
			Logger.comment("gtopcall response:" + gtopcall.getReturnData());
			Logger.verifyEquals(ECode.ERROR400, gtopcall.getCode(), "验证Code");
			// Logger.verifyEquals(ErrorCode.SUCCESSMSG2, gtopcall.getMsg(),
			// "验证Msg");
			// Logger.verifyEquals(true, gtopcall.getOrderPrice()>0,
			// "验证OrderPrice");
			// Logger.verifyEquals(true, gtopcall.getTotalNeedPayPrice()>0,
			// "验证TotalNeedPayPrice");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_GetTradingOrderPrice_003() {
		Logger.start(true,"交易号不存在");
		try {
			/*
			 * Map map = new OrderCallService().createOrder(1); int TradingId =
			 * (Integer) map.get("TradingId");
			 */
			int TradingId = 8044219;// sit
			gtopbean.setTradingId(1);
			// 发送请求
			gtopcall.setData(gtopbean);
			gtopcall.callService();
			Logger.comment("gtopcall send:" + gtopcall.getEntityString());
			Logger.comment("gtopcall response:" + gtopcall.getReturnData());
			Logger.verifyEquals(ECode.FAILED201, gtopcall.getCode(), "验证Code");
			// Logger.verifyEquals(ErrorCode.SUCCESSMSG2, gtopcall.getMsg(),
			// "验证Msg");
			// Logger.verifyEquals(true, gtopcall.getOrderPrice()>0,
			// "验证OrderPrice");
			// Logger.verifyEquals(true, gtopcall.getTotalNeedPayPrice()>0,
			// "验证TotalNeedPayPrice");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

}